﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ECare.Client.templates;
using ECare.BUS;
using ECare.BUS.Data;


namespace ECare.Client.frms
{
    public partial class frmCheckRecords : frmInfo
    {
        public frmCheckRecords()
        {
            InitializeComponent();

            this.Load += frmCheckRecords_Load;
        }

        public int entityId { get; set; }
        public int checktype { get; set; }

        void frmCheckRecords_Load(object sender, EventArgs e)
        {
            //throw new NotImplementedException();

            Check_By.DataSource = UserInfoHelper.GetUsers();
            Check_By.DisplayMember = "UserName";
            Check_By.ValueMember = "UserId";
            
            DataTable dt = new DataTable();

            if (checktype == 0)
                dt = SupplyInfoHelper.GetSupplyStatus();
            else if (checktype == 1)
                dt = SupplyInfoHelper.GetPlanStatus();
            else
            {

            }


            Original_Status.DataSource = dt;
            Original_Status.DisplayMember = "Name";
            Original_Status.ValueMember = "Id";

            Current_Status.DataSource = dt;
            Current_Status.DisplayMember = "Name";
            Current_Status.ValueMember = "Id";


            var worker = new CommonBackgroundWorker();
            worker.m_delegateFunction = new DelegateFunction(
                () => CheckRecordsHelper.GetCheckRecords((CheckType)checktype, entityId)
                );
            worker.RunWorkerCompleted += worker_RunWorkerCompleted;
            worker.RunWorkerAsync();

        }

        void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            //throw new NotImplementedException();

            this.eGridView1.DataSource = e.Result;

        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            this.Close();
        }


    }
}
